#include "os_io.h"
#include <stdarg.h> // va_list
#include "uart.h"
#include "interrupt_controller.h"
#include "string.h"


void print_string(uint8_t * str, uint16_t len)
{
    uint16_t i = 0;

    for (i = 0; i < len; i++) {
        uart_put(str[i]);
    }

    return;
}

/*

static void print_value(uint32_t value)
{
	int8_t count = 28;
	while (count >= 0) {
		uint8_t nibble = ((value >>count) & 0xF);
		if (nibble < 10) {
			uart_put('0' + nibble);
		} else {
			uart_put('A' + nibble - 10);
		}
		count -= 4;
	}

	return;
}
*/

/*
bool printf(char *format, ...)
{
	va_list l;
	uint8_t *ptr = (uint8_t *)format;
	uint32_t value = 0;

	//return true;

	va_start(l, format);

	while (*ptr != 0) {

		if (*ptr != '%') {
			uart_put(*ptr);
		} else {

			if (*(ptr + 1) == '%') {	// case of %% => %
				uart_put(*ptr);
				ptr++;
			} else {
				switch (*(ptr + 1)) {

					case 'x':
						value = va_arg(l, int);
						print_value(value);
						break;
					case 's':
						value = (uint32_t)va_arg(l, char *);
						print_string(value);
						break;
					default:
						printf("INCORRECT FORMAT IN PRINTF. ONLY x/s SUPPORTED.\n");
						break;
				}
				ptr++;
			}
		}
		ptr++;
	}

	va_end(l);

	return TRUE;
}
*/
